import React, { Component } from "react"

export default function asyncComponent(importComponent: any) {
  class AsyncComponent extends Component {
    // constructor(props) {
    //   super(props);
    state = {
      component: null
    }
    // }

    componentDidMount() {
      importComponent().then((mod: any) => {
        console.log(mod, 'mod----')
        this.setState({
          component: mod.default
        })
      })
    }
    render() {
      const Com: any = this.state.component;  // Com
      return Com ? <Com {...this.props} /> : null
    }
  }
  return AsyncComponent
}
